#include "custom_listener/listener.hpp"

#include <iostream>
#include <memory>

#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"

namespace custom_listener{

Listener::Listener(const rclcpp::NodeOptions & options): Node("listener", options){
  auto callback =[this](const typename std_msgs::msg::String::SharedPtr msg) -> void
  {
      RCLCPP_INFO(this->get_logger(), "I heard: [%s]", msg->data.c_str());
      std::flush(std::cout);
  };
  sub_ = create_subscription<std_msgs::msg::String>("chatter", 10, callback);
}

}  // namespace custom_listener

#include "rclcpp_components/register_node_macro.hpp"
RCLCPP_COMPONENTS_REGISTER_NODE(custom_listener::Listener)